# -!- coding: utf-8 -!-
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
触发中移动项目生产的接口
文件：post_msydloan_pro
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

import pymysql
import requests

from interfacetest.baseset.msydloan_api import API_MSYD
from logger import Logger
logger = Logger("post_msydloan_pro").get_log()


db = pymysql.connect(
        host="rm-wz905n9ed226krle9.mysql.rds.aliyuncs.com",
        user="rds2zenglingwei",
        password="oKa#sPoj",
        port=3306,
        use_unicode=True,
        charset="utf8",
        database="msydloandb")
cursor = db.cursor()

headers = {
            'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.80 Safari/537.36',
            'content-Type': 'application/json',
        }

url = 'http://10.16.20.204:90051'
msydloan_url = 'https://zyjk.msxiaodai.com/1'


def spare_handling():
    fu_url = url + '/spare/handling'
    data = API_MSYD['spareHandling']
    req1 = requests.post(fu_url, json=data, headers=headers)
    data = req1.text
    logger.info("临时处理分省业务办理确认文件推送过，但接口未接收到的数据：%s", data)


# 金融局放款、合同存量报送
def push_loan():
    fu_url = msydloan_url + '/test/pushLoan'
    req1 = requests.post(fu_url, headers=headers)
    print("中移动金融局放款、合同存量报送任务完成：", req1, req1.text)


# 金融局还款数据报送
def push_repay():
    fu_url = msydloan_url + '/test/pushRepay'
    req1 = requests.post(fu_url, headers=headers)
    print("中移动金融局还款数据报送任务完成：", req1, req1.text)


def jianXin_mark():
    ful_url = msydloan_url + '/jianxin/mark/runbatch'
    req1 = requests.get(ful_url,headers=headers)
    print("执行自动任务完成：", req1, req1.text)

def jianXin_mark1():
    ful_url = msydloan_url + '/jianxin/screening/runbatch'
    req1 = requests.get(ful_url,headers=headers)
    print("执行自动任务完成：", req1, req1.text)


if __name__ == '__main__':
    t = 4
    if t == 1:
        #spare_handling()
        pass
    elif t == 2:
        push_loan()
    elif t == 3:
        push_repay()
    elif t == 4:
        jianXin_mark()
    elif t == 5:
        jianXin_mark1()
